﻿$(document).ready(function() {
    $("#a_fp1").live("click", function() {
        $("#validationsummary").hide();
        $("#validationsummary").text("");
        $("#spinnermsg").text("");
        $("#spinnermsg").hide();
            $("#t_fp4").hide();
            $("#t_fp3").hide();
            $("#a_fp5").hide();
            $("#a_fp4").show();
            $("#usernamemsg").text("Enter the username corresponding to your dbPoll account and your account details will be sent to you via email.");
            $("#t_fp1").show();
            $("#Status").val(2);
    });

    $("#a_fp2").live("click", function() {
        $("#validationsummary").hide();
        $("#validationsummary").text("");
        $("#spinnermsg").text("");
        $("#spinnermsg").hide();
            $("#t_fp1").show();
            $("#t_fp3").hide();
            $("#t_fp4").hide();
            $("#a_fp4").hide();
            $("#a_fp5").show();
            $("#usernamemsg").text("Enter your username and answer your security question to login.");
            $("#Status").val(0);
    });

    $("#a_fp3").live("click", function() {
        $("#validationsummary").hide();
        $("#validationsummary").text("");
        $("#spinnermsg").text("");
        $("#spinnermsg").hide();
            $("#t_fp1").hide();
            $("#t_fp4").hide();
            $("#t_fp3").show();
            $("#Status").val(3);
    });

    $("#a_fp4").live("click", function() {

    });
});

function forgotPasswordStart() {
    $("#validationsummary").hide();
    $("#validationsummary").text("");
    $("#spinnermsg").text(" Validating...");
    $("#spinnermsg").show();
    $("#spinner").show();
}

function forgotPasswordComplete() {
    if ($("#validationsummary").text() == "" && $("#Status").val() == 0) {
        $("#t_fp3").hide();
        $("#t_fp1").hide();
        $("#t_fp4").show();
        $("#Status").val(1);
        $("#spinnermsg").text("Username found.");
        $("#spinnermsg").show();
    }
    else if ($("#validationsummary").text() == "" && $("#Status").val() == 1) {
        if ($("#Url").val() != '') {
            window.location.replace($("#Url").val());
        }
    }
    else if ($("#validationsummary").text() != "" && $("#Status").val() == 1) {
        $("#t_fp3").hide();
        $("#t_fp1").hide();
        $("#t_fp4").show();
        $("#validationsummary").show();
    }
    else if ($("#validationsummary").text() == "") {
        $("#spinnermsg").text("Login details have been sent to your email address.");
        $("#spinnermsg").show();
    }
    else {
        $("#validationsummary").show();
    }
}